package com.kanshu.ksgb.fastread.doudou.common.business.utils;

import android.content.Context;

import com.kanshu.ksgb.fastread.doudou.R;
import com.kanshu.ksgb.fastread.doudou.common.urlrouter.UrlRouter;
import com.kanshu.ksgb.fastread.doudou.common.util.JsonUtils;
import com.kanshu.ksgb.fastread.doudou.common.util.Utils;
import com.kanshu.ksgb.fastread.doudou.common.business.commonbean.ReaderInputParams;

import java.util.Map;

/**
 * Title:
 * Description:
 * Copyright: Copyright(c)2017
 * Company: 成都古羌科技有限公司
 * CreateTime: 2017/12/8 9:55
 *
 * @author EvanHe
 * @version 1.0
 */
public class ReaderJumpConfig {

    private static long sClickTime = 0L;
    /**
     * 跳转阅读器
     * 注意阅读器参数传入到intent的类型全部是string类型 如果需要转换为boolean int 需要转换一下
     * @param context
     * @param params
     */
    public static void startReaderActivity(Context context, ReaderInputParams params) {
        if (params == null) {
            return;
        }
        Map<String, String> map = JsonUtils.jsonStrToMap(JsonUtils.bean2Json(params));
        StringBuilder sb = new StringBuilder();
        sb.append(context.getString(R.string.base_jump_url))
                .append(context.getString(R.string.reader));
        if(System.currentTimeMillis() - sClickTime > 250) {
            UrlRouter.from(context).jump(Utils.linkUrl(sb.toString(), map));
            sClickTime = System.currentTimeMillis();
        }
    }




}
